/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa165.machineryrental.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author David Katuscak, 359273
 */

@Entity
public class Revision implements Serializable {
    
    @Id
    @GeneratedValue
    private long id;
    
    @Temporal(TemporalType.DATE)
    private Date dateOfRevision;
    
    @Column()
    private String description;
    
    @ManyToOne(fetch = FetchType.EAGER)
    private Machine machine;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public Date getDateOfRevision() {
        return dateOfRevision;
    }

    public void setDateOfRevision(Date dateOfRevision) {
        this.dateOfRevision = dateOfRevision;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
    
   
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (int) (id ^ (id >>> 32));
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Revision other = (Revision) obj;
        if (id != id) {
            return false;
        }
        if (this.dateOfRevision != other.dateOfRevision && (this.dateOfRevision == null || !this.dateOfRevision.equals(other.dateOfRevision))) {
            return false;
        }
        if (!this.description.equals(other.description)) {
            return false;
        }
        if (this.machine != other.machine && (this.machine == null || !this.machine.equals(other.machine))) {
            return false;
        }
        
        return true;
    }

    @Override
    public String toString() {
        return "Revision [id=" + id + ", dateOfRevision=" + dateOfRevision
                + ", description=" + description + "]";
    }
}
